package face.comparer;

/**
 * Created by mazhi on 2018/7/28.
 */

public class Face2FaceHelper {

    private native float compare2Feature(float[] fea1, float[] fea2);

    private native float compare2FeatureV2(float[] fea1, float[] fea2);

    private static volatile Face2FaceHelper instance = null;

    private Face2FaceHelper(){}

    public static Face2FaceHelper getInstance() {
        if (instance == null) {
            synchronized (Face2FaceHelper.class) {
                if (instance == null) {
                    instance = new Face2FaceHelper();
                }
            }
        }
        return instance;
    }

    /**
     * @param fea1 第一个人脸的特征码
     * @param fea2 第二个人脸的特征码
     * @return 2张人脸的相似度，
     */
    public float face2Face(float[] fea1,float[] fea2)
    {
        if (fea1!=null&&fea2!=null)
        {
            return compare2Feature(fea1,fea2);
        }
        return -100;
    }

    /**
     * @param fea1 第一个人脸的特征码
     * @param fea2 第二个人脸的特征码
     * @return 2张人脸的相似度，
     */
    public float face2FaceV2(float[] fea1,float[] fea2)
    {
        if (fea1!=null&&fea2!=null)
        {
            return compare2FeatureV2(fea1,fea2);
        }
        return -100;
    }
}
